﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
using log4net;

namespace Epona.AOP.Log.Impl
{
    public class LogService : ILogService
    {
        public void Log(string log)
        {
            throw new NotImplementedException();
        }

        public void Log(string methodName, string exceptionMessage)
        {
            ILog log = log4net.LogManager.GetLogger(methodName);
            log.Error("error", new System.Exception(exceptionMessage));
        }

        public void Log(MethodInfo methodInfo, string exceptionMessage)
        {
            ILog log = log4net.LogManager.GetLogger(methodInfo.DeclaringType + "." + methodInfo.Name);
            log.Error("error", new System.Exception(exceptionMessage));
        }

        public void Log(string methodName, string exceptionMessage, string parameters, string stackTraceMessage)
        {
            ILog log = log4net.LogManager.GetLogger(methodName);
            log.ErrorFormat("error\nMessage:{0}\nParamter:{1}\nStackTrace:\n{2}\n", exceptionMessage, parameters, stackTraceMessage);
        }
    }
}
